package com.example.back.mapper;

import com.example.back.entity.Like;
import com.example.back.util.StringUtil;

public class LikeMapperProvider {
    public String getQueryLikesSql(Like like) {
        StringBuilder sql = new StringBuilder();
        sql.append("select * from `like` where 1=1");
        if (like.getPostId() != null) {
            sql.append(" and postId =#{postId}");
        }
        if (like.getUserId() != null) {
            sql.append(" and userId =#{userId}");
        }
        if (StringUtil.isNotEmpty(like.getTime())) {
            sql.append(" and time = '").append(like.getTime()).append("'");
        }
        return sql.toString();
    }
}
